#include <stdlib.h>
#include "bufutils.h"


CRecvBuf::CRecvBuf(int size)
{
	buffer = malloc(buf_size);
	if(buffer)
		buf_size = size;
	mode = 0;	
}

CRecvBuf::~CRecvBuf()
{
	if(buffer)
		free(buffer);
	buffer = NULL;	
	buf_size = 0;
}

void CRecvBuf::setConfig(int tsize)
{
	
	target_size = tsize;
}

void* CRecvBuf::getPos(void)
{
	return (buffer+cur_size);
}

int CRecvBuf::getRemain(void)
{
	return (target_size - cur_size);
}

int CRecvBuf::update(int recvcnt)
{
	if(mode==0)
	{
		mode = 1;
		cur_size += recvcnt;
		
	}
}


void CRecvBuf::reset(void)
{
	mode = 0;
	pkt_size = 0;
	target_size = 0;
	cur_size = 0;
}
